<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>云溪网管平台</title>
    <link rel="stylesheet" href="/res/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/res/frame/static/css/style.css">
    <link rel="icon" href="/res/frame/static/image/code.png">
</head>
<body>

<div class="login-main">
    <header class="layui-elip">连发通信智慧管控平台</header>
    <form class="layui-form" autocomplete="off">
        <div class="layui-input-inline">
            <input type="text" id="name" name="name"  required lay-verify="required" placeholder="用户名"  autocomplete="off"  class="layui-input" >
        </div>
        <div class="layui-input-inline">
            <input type="password" name="password" id="password"  placeholder="密码" required lay-verify="required" class="layui-input">
        </div>
        <div class="layui-input-inline login-btn">
            <button class="layui-btn" type="button"  onclick="login()">登录</button>
        </div>
        <hr/>
    </form>
</div>


<script src="/res/frame/layui/layui.js"></script>
<script type="text/javascript" src="/res/frame/static/js/vip_comm.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layer', 'cookie'], function () {
        // 操作对象
        var form = layui.form
            , $ = layui.jquery
            , layer = layui.layer
            , cookie = layui.cookie
        //外部调用的方法
        window.login = function () {
            var param = {};
            param.mName = $("#name").val();
            param.mPwd = $("#password").val();
            $.ajax({
                type: "POST",
                dataType: "json",
                contentType: "application/json",
                url: "/manager/login",
                data: JSON.stringify(param),
                success: function (result) {
                    if (result.code == 200) {
                        var cookietime = new Date();
                        cookietime.setTime(cookietime.getTime() + (60 * 60 * 1000));//coockie保存一小时
                        $.cookie("adminName", result.data.mName, {expires: cookietime,path:"/"});
                        $.cookie("adminId", result.data.pkGuid, {expires: cookietime,path:"/"});
                        $.cookie("mType", result.data.mType, {expires: cookietime,path:"/"});
                        layer.msg("登录成功")
                        window.location.href='/admin/index';
                    } else {
                        layer.msg("用户名密码错误或者用户被锁定")
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    var resultJson = eval('(' + XMLHttpRequest.responseText + ')');
                    layer.msg("登录失败")
                }

            })
        }

    });

</script>
</body>
</html>